from flask import Flask, request

app = Flask(__name__)

@app.route('/post1', methods=['POST'])
def post1():
    return '第一个post请求'

@app.route('/post2', methods=['POST'])
def post2():
    # 如何解析form格式的参数呢？
    username = request.form.get('username')
    password = request.form.get('password')
    return f'第二个post请求, username: {username}, password: {password}'

# 如何解析json格式的参数呢？
@app.route('/post3', methods=['POST'])
def post3():
    request_data = request.get_json()
    username = request_data.get('username')
    password = request_data.get('password')
    return f'第三个post请求, username: {username}, password: {password}'


if __name__ == '__main__':
    app.run(debug=True)